import React from 'react';
import { IndexRoute, Route, IndexRedirect } from 'react-router';
import App from './pages/App.js';

//首页
const Home = (location, cb) => {  
    require.ensure([], require => {
        cb(null, require('./pages/home/index.js').default);
    }, 'home');
};
//开始挖矿
const startMining = (location, cb) => {
    require.ensure([], require => {
        cb(null, require('./pages/startMining/index').default);
    }, 'startMining');
};
//矿产爆块
const minePool = (location, cb) => {
    require.ensure([], require => {
        cb(null, require('./pages/minePool/index').default);
    }, 'minePool');
};
//付款记录
const Payment = (location, cb) => {
    require.ensure([], require => {
        cb(null, require('./pages/payment/index').default);
    }, 'Payment');
};
//区块链浏览器
const blockchain = (location, cb) => {
    require.ensure([], require => {
        cb(null, require('./pages/blockchain/index').default);
    }, 'blockchain');
};
//搜索的地址交易信息
const address = (location, cb) => {
    require.ensure([], require => {
        cb(null, require('./pages/address/index').default);
    }, 'address');
};
//搜索的区块详细信息
const piece = (location, cb) => {
    require.ensure([], require => {
        cb(null, require('./pages/piece/index').default);
    }, 'piece');
};
const createRoutes = () => {
    return (
        <Route path='/home' component={App}>
            <IndexRoute getComponent={Home} />  
            <Route path="/startMining" getComponent={startMining} />
            <Route path="/minePool" getComponent={minePool} />
            <Route path="/payment" getComponent={Payment} />
            <Route path="/blockchain" getComponent={blockchain} />
            <Route path="/address" getComponent={address} />
            <Route path="/piece" getComponent={piece} />
        </Route>
    )
};

export default createRoutes;